home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume90 / unix / flex_2_3 / part08 < prev    next >
Encoding:
Internet Message Format  |  1990-08-19  |  47.7 KB

  1. Path: abcfd20.larc.nasa.gov!amiga-request
  2. From: amiga-request@abcfd20.larc.nasa.gov (Amiga Sources/Binaries Moderator)
  3. Subject: v90i235: flex 2.3 - fast lexical analyzer generator, Part08/13
  4. Reply-To: loftus@wpllabs.uucp (William P Loftus)
  5. Newsgroups: comp.sources.amiga
  6. Message-ID: <comp.sources.amiga:v90i235@abcfd20.larc.nasa.gov>
  7. Date: 19 Aug 90 22:42:59 GMT
  8. Approved: tadguy@uunet.UU.NET (Tad Guy)
  9. X-Mail-Submissions-To: amiga@uunet.uu.net
  10. X-Post-Discussions-To: comp.sys.amiga
  11.  
  12. Submitted-by: loftus@wpllabs.uucp (William P Loftus)
  13. Posting-number: Volume 90, Issue 235
  14. Archive-name: unix/flex-2.3/part08
  15.  
  16. #!/bin/sh
  17. # This is a shell archive.  Remove anything before this line, then unpack
  18. # it by saving it into a file and typing "sh file".  To overwrite existing
  19. # files, type "sh file -c".  You can also feed this as standard input via
  20. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  21. # will see the following message at the end:
  22. #        "End of archive 8 (of 13)."
  23. # Contents:  parse.c
  24. # Wrapped by tadguy@abcfd20 on Sun Aug 19 18:41:47 1990
  25. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  26. if test -f 'parse.c' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'parse.c'\"
  28. else
  29. echo shar: Extracting \"'parse.c'\" \(45081 characters\)
  30. sed "s/^X//" >'parse.c' <<'END_OF_FILE'
  31. X
  32. X/*  A Bison parser, made from parse.y  */
  33. X
  34. X#define    CHAR    258
  35. X#define    NUMBER    259
  36. X#define    SECTEND    260
  37. X#define    SCDECL    261
  38. X#define    XSCDECL    262
  39. X#define    WHITESPACE    263
  40. X#define    NAME    264
  41. X#define    PREVCCL    265
  42. X#define    EOF_OP    266
  43. X
  44. X#line 6 "parse.y"
  45. X
  46. X/*-
  47. X * Copyright (c) 1990 The Regents of the University of California.
  48. X * All rights reserved.
  49. X *
  50. X * This code is derived from software contributed to Berkeley by
  51. X * Vern Paxson.
  52. X * 
  53. X * The United States Government has rights in this work pursuant
  54. X * to contract no. DE-AC03-76SF00098 between the United States
  55. X * Department of Energy and the University of California.
  56. X *
  57. X * Redistribution and use in source and binary forms are permitted provided
  58. X * that: (1) source distributions retain this entire copyright notice and
  59. X * comment, and (2) distributions including binaries display the following
  60. X * acknowledgement:  ``This product includes software developed by the
  61. X * University of California, Berkeley and its contributors'' in the
  62. X * documentation or other materials provided with the distribution and in
  63. X * all advertising materials mentioning features or use of this software.
  64. X * Neither the name of the University nor the names of its contributors may
  65. X * be used to endorse or promote products derived from this software without
  66. X * specific prior written permission.
  67. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  68. X * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  69. X * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  70. X */
  71. X
  72. X#ifndef lint
  73. Xstatic char rcsid[] =
  74. X    "@(#) $Header: /usr/fsys/odin/a/vern/flex/RCS/parse.y,v 2.7 90/06/27 23:48:31 vern Exp $ (LBL)";
  75. X#endif
  76. X
  77. X#include "flexdef.h"
  78. X
  79. Xint pat, scnum, eps, headcnt, trailcnt, anyccl, lastchar, i, actvp, rulelen;
  80. Xint trlcontxt, xcluflg, cclsorted, varlength, variable_trail_rule;
  81. XChar clower();
  82. Xvoid build_eof_action();
  83. Xvoid yyerror( char * );
  84. X
  85. Xstatic int madeany = false;  /* whether we've made the '.' character class */
  86. Xint previous_continued_action;    /* whether the previous rule's action was '|' */
  87. X
  88. X
  89. X#ifndef YYLTYPE
  90. Xtypedef
  91. X  struct yyltype
  92. X    {
  93. X      int timestamp;
  94. X      int first_line;
  95. X      int first_column;
  96. X      int last_line;
  97. X      int last_column;
  98. X      char *text;
  99. X   }
  100. X  yyltype;
  101. X
  102. X#define YYLTYPE yyltype
  103. X#endif
  104. X
  105. X#define    YYACCEPT    return(0)
  106. X#define    YYABORT    return(1)
  107. X#define    YYERROR    goto yyerrlab
  108. X#ifndef YYSTYPE
  109. X#define YYSTYPE int
  110. X#endif
  111. X#ifndef stdin
  112. X#include <stdio.h>
  113. X#endif
  114. X
  115. X#ifndef __STDC__
  116. X#define const
  117. X#endif
  118. X
  119. X
  120. X
  121. X#define    YYFINAL        81
  122. X#define    YYFLAG        -32768
  123. X#define    YYNTBASE    32
  124. X
  125. X#define YYTRANSLATE(x) ((unsigned)(x) <= 266 ? yytranslate[x] : 51)
  126. X
  127. Xstatic const char yytranslate[] = {     0,
  128. X     2,     2,     2,     2,     2,     2,     2,     2,     2,    12,
  129. X     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  130. X     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  131. X     2,     2,     2,    26,     2,    17,     2,     2,     2,    27,
  132. X    28,    20,    21,    16,    31,    25,    19,     2,     2,     2,
  133. X     2,     2,     2,     2,     2,     2,     2,     2,     2,    14,
  134. X     2,    15,    22,     2,     2,     2,     2,     2,     2,     2,
  135. X     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  136. X     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  137. X    29,     2,    30,    13,     2,     2,     2,     2,     2,     2,
  138. X     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  139. X     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  140. X     2,     2,    23,    18,    24,     2,     2,     2,     2,     2,
  141. X     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  142. X     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  143. X     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  144. X     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  145. X     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  146. X     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  147. X     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  148. X     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  149. X     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  150. X     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  151. X     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  152. X     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  153. X     2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
  154. X     6,     7,     8,     9,    10,    11
  155. X};
  156. X
  157. Xstatic const short yyrline[] = {     0,
  158. X    52,    76,    85,    86,    87,    91,    94,   104,   108,   111,
  159. X   114,   118,   119,   122,   133,   153,   164,   188,   199,   202,
  160. X   221,   225,   228,   238,   247,   251,   308,   311,   351,   367,
  161. X   373,   378,   403,   411,   415,   422,   429,   436,   454,   468,
  162. X   486,   508,   525,   532,   535,   538,   549,   552,   566,   594,
  163. X   606,   614,   625
  164. X};
  165. X
  166. Xstatic const char * const yytname[] = {     0,
  167. X"error","$illegal.","CHAR","NUMBER","SECTEND","SCDECL","XSCDECL","WHITESPACE","NAME","PREVCCL",
  168. X"EOF_OP","'\\n'","'^'","'<'","'>'","','","'$'","'|'","'/'","'*'",
  169. X"'+'","'?'","'{'","'}'","'.'","'\"'","'('","')'","'['","']'",
  170. X"'-'","goal"
  171. X};
  172. X
  173. Xstatic const short yyr1[] = {     0,
  174. X    32,    33,    34,    34,    34,    35,    36,    36,    37,    37,
  175. X    37,    38,    38,    39,    40,    40,    40,    40,    40,    40,
  176. X    40,    41,    42,    42,    42,    43,    43,    43,    43,    44,
  177. X    44,    45,    46,    46,    47,    47,    47,    47,    47,    47,
  178. X    47,    47,    47,    47,    47,    47,    48,    48,    49,    49,
  179. X    49,    50,    50
  180. X};
  181. X
  182. Xstatic const short yyr2[] = {     0,
  183. X     5,     0,     5,     0,     2,     1,     1,     1,     3,     1,
  184. X     1,     4,     0,     0,     3,     2,     2,     1,     2,     1,
  185. X     1,     3,     3,     1,     1,     2,     3,     2,     1,     3,
  186. X     1,     2,     2,     1,     2,     2,     2,     6,     5,     4,
  187. X     1,     1,     1,     3,     3,     1,     3,     4,     4,     2,
  188. X     0,     2,     0
  189. X};
  190. X
  191. Xstatic const short yydefact[] = {     2,
  192. X     0,     0,     0,     5,     6,     7,     8,    13,     0,    14,
  193. X     0,     0,    11,    10,     0,    21,    46,    43,    20,     0,
  194. X     0,    41,    53,     0,    51,     0,     0,    18,    29,     0,
  195. X    31,    34,    42,     0,     3,    17,    25,    24,     0,     0,
  196. X     0,    51,     0,    12,    19,     0,    16,    28,     0,    32,
  197. X    26,    33,    35,    36,    37,     0,     9,    22,     0,    52,
  198. X    44,    45,     0,    50,    47,    15,    30,    27,     0,    23,
  199. X    48,     0,     0,    40,    49,     0,    39,    38,     0,     0,
  200. X     0
  201. X};
  202. X
  203. Xstatic const short yydefgoto[] = {    79,
  204. X     1,     3,     8,     9,    15,    10,    12,    26,    27,    39,
  205. X    28,    29,    30,    31,    32,    33,    43,    40
  206. X};
  207. X
  208. Xstatic const short yypact[] = {-32768,
  209. X    55,    -2,    63,-32768,-32768,-32768,-32768,-32768,    16,-32768,
  210. X    12,     1,-32768,-32768,    51,-32768,-32768,-32768,-32768,    19,
  211. X    33,-32768,-32768,    19,    -6,     8,    28,-32768,    54,    19,
  212. X    19,    44,-32768,    38,-32768,-32768,-32768,-32768,    34,    14,
  213. X   -10,-32768,     2,-32768,-32768,    19,-32768,-32768,    19,-32768,
  214. X    57,    44,-32768,-32768,-32768,    48,-32768,-32768,    49,-32768,
  215. X-32768,-32768,     3,     6,-32768,-32768,    19,-32768,    27,-32768,
  216. X-32768,    73,    -1,-32768,-32768,    53,-32768,-32768,    78,    79,
  217. X-32768
  218. X};
  219. X
  220. Xstatic const short yypgoto[] = {-32768,
  221. X-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  222. X   -11,    -5,-32768,    31,   -31,-32768,    39,-32768
  223. X};
  224. X
  225. X
  226. X#define    YYLAST        81
  227. X
  228. X
  229. Xstatic const short yytable[] = {    52,
  230. X    -1,    16,    76,    17,    64,    64,    42,    49,    36,     4,
  231. X    18,    19,    13,    20,    21,    47,    60,    62,    41,    44,
  232. X    14,    17,    77,    11,    51,    22,    23,    24,    18,    25,
  233. X    17,    65,    71,    37,    66,    52,    72,    18,    45,    61,
  234. X    46,    38,    73,    22,    23,    24,    57,    25,    58,    59,
  235. X    74,    69,    22,    23,    24,     2,    25,    70,    34,    -4,
  236. X    -4,    -4,    35,    53,    54,    55,    56,     5,     6,     7,
  237. X    48,    49,    50,    68,    49,    75,    78,    80,    81,    67,
  238. X    63
  239. X};
  240. X
  241. Xstatic const short yycheck[] = {    31,
  242. X     0,     1,     4,     3,     3,     3,    13,    18,    20,    12,
  243. X    10,    11,     1,    13,    14,    27,     3,    28,    24,    12,
  244. X     9,     3,    24,     8,    30,    25,    26,    27,    10,    29,
  245. X     3,    30,    30,     1,    46,    67,    31,    10,    11,    26,
  246. X    13,     9,    16,    25,    26,    27,     9,    29,    15,    16,
  247. X    24,     4,    25,    26,    27,     1,    29,     9,     8,     5,
  248. X     6,     7,    12,    20,    21,    22,    23,     5,     6,     7,
  249. X    17,    18,    19,    17,    18,     3,    24,     0,     0,    49,
  250. X    42
  251. X};
  252. X#define YYPURE 1
  253. X
  254. X#line 2 "bison.simple"
  255. X
  256. X/* Skeleton output parser for bison,
  257. X   copyright (C) 1984 Bob Corbett and Richard Stallman
  258. X
  259. X                       NO WARRANTY
  260. X
  261. X  BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
  262. XNO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW.  EXCEPT
  263. XWHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
  264. XRICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS PROGRAM "AS IS"
  265. XWITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
  266. XBUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  267. XFITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY
  268. XAND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE PROGRAM PROVE
  269. XDEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
  270. XCORRECTION.
  271. X
  272. X IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
  273. XSTALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY
  274. XWHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE
  275. XLIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR
  276. XOTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
  277. XUSE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR
  278. XDATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR
  279. XA FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS
  280. XPROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
  281. XDAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
  282. X
  283. X                GENERAL PUBLIC LICENSE TO COPY
  284. X
  285. X  1. You may copy and distribute verbatim copies of this source file
  286. Xas you receive it, in any medium, provided that you conspicuously and
  287. Xappropriately publish on each copy a valid copyright notice "Copyright
  288. X(C) 1985 Free Software Foundation, Inc."; and include following the
  289. Xcopyright notice a verbatim copy of the above disclaimer of warranty
  290. Xand of this License.  You may charge a distribution fee for the
  291. Xphysical act of transferring a copy.
  292. X
  293. X  2. You may modify your copy or copies of this source file or
  294. Xany portion of it, and copy and distribute such modifications under
  295. Xthe terms of Paragraph 1 above, provided that you also do the following:
  296. X
  297. X    a) cause the modified files to carry prominent notices stating
  298. X    that you changed the files and the date of any change; and
  299. X
  300. X    b) cause the whole of any work that you distribute or publish,
  301. X    that in whole or in part contains or is a derivative of this
  302. X    program or any part thereof, to be licensed at no charge to all
  303. X    third parties on terms identical to those contained in this
  304. X    License Agreement (except that you may choose to grant more extensive
  305. X    warranty protection to some or all third parties, at your option).
  306. X
  307. X    c) You may charge a distribution fee for the physical act of
  308. X    transferring a copy, and you may at your option offer warranty
  309. X    protection in exchange for a fee.
  310. X
  311. XMere aggregation of another unrelated program with this program (or its
  312. Xderivative) on a volume of a storage or distribution medium does not bring
  313. Xthe other program under the scope of these terms.
  314. X
  315. X  3. You may copy and distribute this program (or a portion or derivative
  316. Xof it, under Paragraph 2) in object code or executable form under the terms
  317. Xof Paragraphs 1 and 2 above provided that you also do one of the following:
  318. X
  319. X    a) accompany it with the complete corresponding machine-readable
  320. X    source code, which must be distributed under the terms of
  321. X    Paragraphs 1 and 2 above; or,
  322. X
  323. X    b) accompany it with a written offer, valid for at least three
  324. X    years, to give any third party free (except for a nominal
  325. X    shipping charge) a complete machine-readable copy of the
  326. X    corresponding source code, to be distributed under the terms of
  327. X    Paragraphs 1 and 2 above; or,
  328. X
  329. X    c) accompany it with the information you received as to where the
  330. X    corresponding source code may be obtained.  (This alternative is
  331. X    allowed only for noncommercial distribution and only if you
  332. X    received the program in object code or executable form alone.)
  333. X
  334. XFor an executable file, complete source code means all the source code for
  335. Xall modules it contains; but, as a special exception, it need not include
  336. Xsource code for modules which are standard libraries that accompany the
  337. Xoperating system on which the executable file runs.
  338. X
  339. X  4. You may not copy, sublicense, distribute or transfer this program
  340. Xexcept as expressly provided under this License Agreement.  Any attempt
  341. Xotherwise to copy, sublicense, distribute or transfer this program is void and
  342. Xyour rights to use the program under this License agreement shall be
  343. Xautomatically terminated.  However, parties who have received computer
  344. Xsoftware programs from you with this License Agreement will not have
  345. Xtheir licenses terminated so long as such parties remain in full compliance.
  346. X
  347. X  5. If you wish to incorporate parts of this program into other free
  348. Xprograms whose distribution conditions are different, write to the Free
  349. XSoftware Foundation at 675 Mass Ave, Cambridge, MA 02139.  We have not yet
  350. Xworked out a simple rule that can be stated here, but we will often permit
  351. Xthis.  We will be guided by the two goals of preserving the free status of
  352. Xall derivatives of our free software and of promoting the sharing and reuse of
  353. Xsoftware.
  354. X
  355. X
  356. XIn other words, you are welcome to use, share and improve this program.
  357. XYou are forbidden to forbid anyone else to use, share and improve
  358. Xwhat you give them.   Help stamp out software-hoarding!  */
  359. X
  360. X/* This is the parser code that is written into each bison parser
  361. X  when the %semantic_parser declaration is not specified in the grammar.
  362. X  It was written by Richard Stallman by simplifying the hairy parser
  363. X  used when %semantic_parser is specified.  */
  364. X
  365. X/* Note: there must be only one dollar sign in this file.
  366. X   It is replaced by the list of actions, each action
  367. X   as one case of the switch.  */
  368. X
  369. X#ifdef AMIGA
  370. X
  371. X#define bzero(b, length) memset((b),'\0',(length))
  372. X#define bcopy(b1, b2, length) memcpy((b1),(b2),(length))
  373. X#define bcmp(b1, b2, length)  memcmp((b1),(b2),(length))
  374. X
  375. Xvoid
  376. Xmemory_full ()
  377. X{
  378. X  printf ("Memory exhausted.\n");
  379. X  exit(1);
  380. X}
  381. X
  382. X
  383. Xchar *
  384. Xxmalloc (size)
  385. X     int size;
  386. X{
  387. X  extern char *malloc ();
  388. X  register char *ptr = malloc (size);
  389. X  if (ptr != 0) return (ptr);
  390. X  memory_full ();
  391. X  /*NOTREACHED*/
  392. X}
  393. X
  394. Xchar *
  395. Xxrealloc (old, size)
  396. X     char *old;
  397. X     int size;
  398. X{
  399. X  extern char *realloc ();
  400. X  register char *ptr = realloc (old, size);
  401. X  if (ptr != 0) return (ptr);
  402. X  memory_full ();
  403. X  /*NOTREACHED*/
  404. X}
  405. X
  406. Xchar *
  407. Xxcalloc (number, size)
  408. X     int number, size;
  409. X{
  410. X  extern char *malloc ();
  411. X  register int total = number * size;
  412. X  register char *ptr = malloc (total);
  413. X  if (ptr != 0)
  414. X    {
  415. X      if (total > 100)
  416. X        bzero (ptr, total);
  417. X      else {
  418. X        /* It's not too long, so loop, zeroing by longs.
  419. X           It must be safe because malloc values are always well aligned.  */
  420. X        register long *zp = (long *) ptr;
  421. X        register long *zl = (long *) (ptr + total - 4);
  422. X        register int i = total - 4;
  423. X        while (zp < zl)
  424. X          *zp++ = 0;
  425. X        if (i < 0)
  426. X          i = 0;
  427. X        while (i < total)
  428. X          ptr[i++] = 0;
  429. X      }
  430. X      return ptr;
  431. X    }
  432. X  memory_full ();
  433. X  /*NOTREACHED*/
  434. X}
  435. X
  436. X/*
  437. X        alloca -- (mostly) portable public-domain implementation -- D A Gwyn
  438. X
  439. X        last edit:      86/05/30        rms
  440. X           include config.h, since on VMS it renames some symbols.
  441. X           Use xmalloc instead of malloc.
  442. X
  443. X        This implementation of the PWB library alloca() function,
  444. X        which is used to allocate space off the run-time stack so
  445. X        that it is automatically reclaimed upon procedure exit,
  446. X        was inspired by discussions with J. Q. Johnson of Cornell.
  447. X
  448. X        It should work under any C implementation that uses an
  449. X        actual procedure stack (as opposed to a linked list of
  450. X        frames).  There are some preprocessor constants that can
  451. X        be defined when compiling for your specific system, for
  452. X        improved efficiency; however, the defaults should be okay.
  453. X
  454. X        The general concept of this implementation is to keep
  455. X        track of all alloca()-allocated blocks, and reclaim any
  456. X        that are found to be deeper in the stack than the current
  457. X        invocation.  This heuristic does not reclaim storage as
  458. X        soon as it becomes invalid, but it will do so eventually.
  459. X
  460. X        As a special case, alloca(0) reclaims storage without
  461. X        allocating any.  It is a good idea to use alloca(0) in
  462. X        your main control loop, etc. to force garbage collection.
  463. X*/
  464. X
  465. Xtypedef char    *pointer;               /* generic pointer type */
  466. X
  467. Xextern void     free();
  468. Xextern pointer  xmalloc();
  469. X
  470. X/*
  471. X        Define STACK_DIRECTION if you know the direction of stack
  472. X        growth for your system; otherwise it will be automatically
  473. X        deduced at run-time.
  474. X
  475. X        STACK_DIRECTION > 0 => grows toward higher addresses
  476. X        STACK_DIRECTION < 0 => grows toward lower addresses
  477. X        STACK_DIRECTION = 0 => direction of growth unknown
  478. X*/
  479. X
  480. X#define STACK_DIRECTION -1
  481. X
  482. X#define STACK_DIR       STACK_DIRECTION /* known at compile-time */
  483. X
  484. X/*
  485. X        An "alloca header" is used to:
  486. X        (a) chain together all alloca()ed blocks;
  487. X        (b) keep track of stack depth.
  488. X
  489. X        It is very important that sizeof(header) agree with malloc()
  490. X        alignment chunk size.  The following default should work okay.
  491. X*/
  492. X
  493. X#ifndef ALIGN_SIZE
  494. X#define ALIGN_SIZE      sizeof(double)
  495. X#endif
  496. X
  497. Xtypedef union hdr
  498. X{
  499. X  char  align[ALIGN_SIZE];      /* to force sizeof(header) */
  500. X  struct
  501. X    {
  502. X      union hdr *next;          /* for chaining headers */
  503. X      char *deep;               /* for stack depth measure */
  504. X    } h;
  505. X} header;
  506. X
  507. X/*
  508. X        alloca( size ) returns a pointer to at least `size' bytes of
  509. X        storage which will be automatically reclaimed upon exit from
  510. X        the procedure that called alloca().  Originally, this space
  511. X        was supposed to be taken from the current stack frame of the
  512. X        caller, but that method cannot be made to work for some
  513. X        implementations of C, for example under Gould's UTX/32.
  514. X*/
  515. X
  516. Xstatic header *last_alloca_header = NULL; /* -> last alloca header */
  517. X
  518. Xpointer
  519. Xalloca (size)                   /* returns pointer to storage */
  520. X     unsigned   size;           /* # bytes to allocate */
  521. X{
  522. X  auto char     probe;          /* probes stack depth: */
  523. X  register char *depth = &probe;
  524. X
  525. X                                /* Reclaim garbage, defined as all alloca()ed storage that
  526. X                                   was allocated from deeper in the stack than currently. */
  527. X
  528. X  {
  529. X    register header     *hp;    /* traverses linked list */
  530. X
  531. X    for (hp = last_alloca_header; hp != NULL;)
  532. X      if (STACK_DIR > 0 && hp->h.deep > depth
  533. X          || STACK_DIR < 0 && hp->h.deep < depth)
  534. X        {
  535. X          register header       *np = hp->h.next;
  536. X
  537. X          free ((pointer) hp);  /* collect garbage */
  538. X
  539. X          hp = np;              /* -> next header */
  540. X        }
  541. X      else
  542. X        break;                  /* rest are not deeper */
  543. X
  544. X    last_alloca_header = hp;    /* -> last valid storage */
  545. X  }
  546. X
  547. X  if (size == 0)
  548. X    return NULL;                /* no allocation required */
  549. X
  550. X  /* Allocate combined header + user data storage. */
  551. X
  552. X  {
  553. X    register pointer    new = xmalloc (sizeof (header) + size);
  554. X    /* address of header */
  555. X
  556. X    ((header *)new)->h.next = last_alloca_header;
  557. X    ((header *)new)->h.deep = depth;
  558. X
  559. X    last_alloca_header = (header *)new;
  560. X
  561. X    /* User storage begins just after header. */
  562. X
  563. X    return (pointer)((char *)new + sizeof(header));
  564. X  }
  565. X}
  566. X#endif
  567. X
  568. X
  569. X
  570. X#define yyerrok         (yyerrstatus = 0)
  571. X#define yyclearin       (yychar = YYEMPTY)
  572. X#define YYEMPTY         -2
  573. X#define YYEOF           0
  574. X#define YYFAIL          goto yyerrlab;
  575. X
  576. X#define YYTERROR        1
  577. X
  578. X#ifndef YYIMPURE
  579. X#define YYLEX           yylex()
  580. X#endif
  581. X
  582. X#ifndef YYPURE
  583. X#define YYLEX           yylex(&yylval, &yylloc)
  584. X#endif
  585. X
  586. X/* If nonreentrant, generate the variables here */
  587. X
  588. X#ifndef YYIMPURE
  589. X
  590. Xint     yychar;                 /*  the lookahead symbol                */
  591. XYYSTYPE yylval;                 /*  the semantic value of the           */
  592. X                                /*  lookahead symbol                    */
  593. X
  594. XYYLTYPE yylloc;                 /*  location data for the lookahead     */
  595. X                                /*  symbol                              */
  596. X
  597. Xint yynerr;                     /*  number of parse errors so far       */
  598. X
  599. X#ifdef YYDEBUG
  600. Xint yydebug = 0;                /*  nonzero means print parse trace     */
  601. X#endif
  602. X
  603. X#endif  /* YYIMPURE */
  604. X
  605. X
  606. X/*  YYMAXDEPTH indicates the initial size of the parser's stacks        */
  607. X
  608. X#ifndef YYMAXDEPTH
  609. X#define YYMAXDEPTH 200
  610. X#endif
  611. X
  612. X/*  YYMAXLIMIT is the maximum size the stacks can grow to
  613. X    (effective only if the built-in stack extension method is used).  */
  614. X
  615. X#ifndef YYMAXLIMIT
  616. X#define YYMAXLIMIT 10000
  617. X#endif
  618. X
  619. X
  620. X#line 165 "bison.simple"
  621. Xint
  622. Xyyparse()
  623. X{
  624. X  register int yystate;
  625. X  register int yyn;
  626. X  register short *yyssp;
  627. X  register YYSTYPE *yyvsp;
  628. X  YYLTYPE *yylsp;
  629. X  int yyerrstatus;      /*  number of tokens to shift before error messages enabled */
  630. X  int yychar1;          /*  lookahead token as an internal (translated) token number */
  631. X
  632. X  short yyssa[YYMAXDEPTH];      /*  the state stack                     */
  633. X  YYSTYPE yyvsa[YYMAXDEPTH];    /*  the semantic value stack            */
  634. X  YYLTYPE yylsa[YYMAXDEPTH];    /*  the location stack                  */
  635. X
  636. X  short *yyss = yyssa;          /*  refer to the stacks thru separate pointers */
  637. X  YYSTYPE *yyvs = yyvsa;        /*  to allow yyoverflow to reallocate them elsewhere */
  638. X  YYLTYPE *yyls = yylsa;
  639. X
  640. X  int yymaxdepth = YYMAXDEPTH;
  641. X
  642. X#ifndef YYPURE
  643. X  int yychar;
  644. X  YYSTYPE yylval;
  645. X  YYLTYPE yylloc;
  646. X#endif
  647. X
  648. X#ifdef YYDEBUG
  649. X  extern int yydebug;
  650. X#endif
  651. X
  652. X
  653. X  YYSTYPE yyval;                /*  the variable used to return         */
  654. X                                /*  semantic values from the action     */
  655. X                                /*  routines                            */
  656. X
  657. X  int yylen;
  658. X
  659. X#ifdef YYDEBUG
  660. X  if (yydebug)
  661. X    fprintf(stderr, "Starting parse\n");
  662. X#endif
  663. X
  664. X  yystate = 0;
  665. X  yyerrstatus = 0;
  666. X  yynerr = 0;
  667. X  yychar = YYEMPTY;             /* Cause a token to be read.  */
  668. X
  669. X  /* Initialize stack pointers.
  670. X     Waste one element of value and location stack
  671. X     so that they stay on the same level as the state stack.  */
  672. X
  673. X  yyssp = yyss - 1;
  674. X  yyvsp = yyvs;
  675. X  yylsp = yyls;
  676. X
  677. X/* Push a new state, which is found in  yystate  .  */
  678. X/* In all cases, when you get here, the value and location stacks
  679. X   have just been pushed. so pushing a state here evens the stacks.  */
  680. Xyynewstate:
  681. X
  682. X  *++yyssp = yystate;
  683. X
  684. X  if (yyssp >= yyss + yymaxdepth - 1)
  685. X    {
  686. X      /* Give user a chance to reallocate the stack */
  687. X      /* Use copies of these so that the &'s don't force the real ones into memory. */
  688. X      YYSTYPE *yyvs1 = yyvs;
  689. X      YYLTYPE *yyls1 = yyls;
  690. X      short *yyss1 = yyss;
  691. X
  692. X      /* Get the current used size of the three stacks, in elements.  */
  693. X      int size = yyssp - yyss + 1;
  694. X
  695. X#ifdef yyoverflow
  696. X      /* Each stack pointer address is followed by the size of
  697. X         the data in use in that stack, in bytes.  */
  698. X      yyoverflow("parser stack overflow",
  699. X                 &yyss1, size * sizeof (*yyssp),
  700. X                 &yyvs1, size * sizeof (*yyvsp),
  701. X                 &yyls1, size * sizeof (*yylsp),
  702. X                 &yymaxdepth);
  703. X
  704. X      yyss = yyss1; yyvs = yyvs1; yyls = yyls1;
  705. X#else /* no yyoverflow */
  706. X      /* Extend the stack our own way.  */
  707. X      if (yymaxdepth >= YYMAXLIMIT)
  708. X        yyerror("parser stack overflow");
  709. X      yymaxdepth *= 2;
  710. X      if (yymaxdepth > YYMAXLIMIT)
  711. X        yymaxdepth = YYMAXLIMIT;
  712. X      yyss = (short *) alloca (yymaxdepth * sizeof (*yyssp));
  713. X      bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
  714. X      yyvs = (YYSTYPE *) alloca (yymaxdepth * sizeof (*yyvsp));
  715. X      bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
  716. X#ifdef YYLSP_NEEDED
  717. X      yyls = (YYLTYPE *) alloca (yymaxdepth * sizeof (*yylsp));
  718. X      bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
  719. X#endif
  720. X#endif /* no yyoverflow */
  721. X
  722. X      yyssp = yyss + size - 1;
  723. X      yyvsp = yyvs + size - 1;
  724. X#ifdef YYLSP_NEEDED
  725. X      yylsp = yyls + size - 1;
  726. X#endif
  727. X
  728. X#ifdef YYDEBUG
  729. X      if (yydebug)
  730. X        fprintf(stderr, "Stack size increased to %d\n", yymaxdepth);
  731. X#endif
  732. X
  733. X      if (yyssp >= yyss + yymaxdepth - 1)
  734. X        YYERROR;
  735. X    }
  736. X
  737. X#ifdef YYDEBUG
  738. X  if (yydebug)
  739. X    fprintf(stderr, "Entering state %d\n", yystate);
  740. X#endif
  741. X
  742. X/* Do appropriate processing given the current state.  */
  743. X/* Read a lookahead token if we need one and don't already have one.  */
  744. Xyyresume:
  745. X
  746. X  /* First try to decide what to do without reference to lookahead token.  */
  747. X
  748. X  yyn = yypact[yystate];
  749. X  if (yyn == YYFLAG)
  750. X    goto yydefault;
  751. X
  752. X  /* Not known => get a lookahead token if don't already have one.  */
  753. X
  754. X  /* yychar is either YYEMPTY or YYEOF
  755. X     or a valid token in external form.  */
  756. X
  757. X  if (yychar == YYEMPTY)
  758. X    {
  759. X#ifdef YYDEBUG
  760. X      if (yydebug)
  761. X        fprintf(stderr, "Reading a token: ");
  762. X#endif
  763. X      yychar = YYLEX;
  764. X    }
  765. X
  766. X  /* Convert token to internal form (in yychar1) for indexing tables with */
  767. X
  768. X  if (yychar <= 0)              /* This means end of input. */
  769. X    {
  770. X      yychar1 = 0;
  771. X      yychar = YYEOF;           /* Don't call YYLEX any more */
  772. X
  773. X#ifdef YYDEBUG
  774. X      if (yydebug)
  775. X        fprintf(stderr, "Now at end of input.\n");
  776. X#endif
  777. X    }
  778. X  else
  779. X    {
  780. X      yychar1 = YYTRANSLATE(yychar);
  781. X
  782. X#ifdef YYDEBUG
  783. X      if (yydebug)
  784. X        fprintf(stderr, "Next token is %d (%s)\n", yychar, yytname[yychar1]);
  785. X#endif
  786. X    }
  787. X
  788. X  yyn += yychar1;
  789. X  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  790. X    goto yydefault;
  791. X
  792. X  yyn = yytable[yyn];
  793. X
  794. X  /* yyn is what to do for this token type in this state.
  795. X     Negative => reduce, -yyn is rule number.
  796. X     Positive => shift, yyn is new state.
  797. X       New state is final state => don't bother to shift,
  798. X       just return success.
  799. X     0, or most negative number => error.  */
  800. X
  801. X  if (yyn < 0)
  802. X    {
  803. X      if (yyn == YYFLAG)
  804. X        goto yyerrlab;
  805. X      yyn = -yyn;
  806. X      goto yyreduce;
  807. X    }
  808. X  else if (yyn == 0)
  809. X    goto yyerrlab;
  810. X
  811. X  if (yyn == YYFINAL)
  812. X    YYACCEPT;
  813. X
  814. X  /* Shift the lookahead token.  */
  815. X
  816. X#ifdef YYDEBUG
  817. X  if (yydebug)
  818. X    fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  819. X#endif
  820. X
  821. X  /* Discard the token being shifted unless it is eof.  */
  822. X  if (yychar != YYEOF)
  823. X    yychar = YYEMPTY;
  824. X
  825. X  *++yyvsp = yylval;
  826. X#ifdef YYLSP_NEEDED
  827. X  *++yylsp = yylloc;
  828. X#endif
  829. X
  830. X  /* count tokens shifted since error; after three, turn off error status.  */
  831. X  if (yyerrstatus) yyerrstatus--;
  832. X
  833. X  yystate = yyn;
  834. X  goto yynewstate;
  835. X
  836. X/* Do the default action for the current state.  */
  837. Xyydefault:
  838. X
  839. X  yyn = yydefact[yystate];
  840. X  if (yyn == 0)
  841. X    goto yyerrlab;
  842. X
  843. X/* Do a reduction.  yyn is the number of a rule to reduce with.  */
  844. Xyyreduce:
  845. X  yylen = yyr2[yyn];
  846. X  yyval = yyvsp[1-yylen]; /* implement default value of the action */
  847. X
  848. X#ifdef YYDEBUG
  849. X  if (yydebug)
  850. X    {
  851. X      if (yylen == 1)
  852. X        fprintf (stderr, "Reducing 1 value via line %d, ",
  853. X                 yyrline[yyn]);
  854. X      else
  855. X        fprintf (stderr, "Reducing %d values via line %d, ",
  856. X                 yylen, yyrline[yyn]);
  857. X    }
  858. X#endif
  859. X
  860. X
  861. X  switch (yyn) {
  862. X
  863. Xcase 1:
  864. X#line 53 "parse.y"
  865. X{ /* add default rule */
  866. X            int def_rule;
  867. X
  868. X            pat = cclinit();
  869. X            cclnegate( pat );
  870. X
  871. X            def_rule = mkstate( -pat );
  872. X
  873. X            finish_rule( def_rule, false, 0, 0 );
  874. X
  875. X            for ( i = 1; i <= lastsc; ++i )
  876. X                scset[i] = mkbranch( scset[i], def_rule );
  877. X
  878. X            if ( spprdflt )
  879. X                fputs( "YY_FATAL_ERROR( \"flex scanner jammed\" )",
  880. X                   temp_action_file );
  881. X            else
  882. X                fputs( "ECHO", temp_action_file );
  883. X
  884. X            fputs( ";\n\tYY_BREAK\n", temp_action_file );
  885. X            ;
  886. X    break;}
  887. Xcase 2:
  888. X#line 77 "parse.y"
  889. X{
  890. X            /* initialize for processing rules */
  891. X
  892. X            /* create default DFA start condition */
  893. X            scinstal( "INITIAL", false );
  894. X            ;
  895. X    break;}
  896. Xcase 5:
  897. X#line 88 "parse.y"
  898. X{ synerr( "unknown error processing section 1" ); ;
  899. X    break;}
  900. Xcase 7:
  901. X#line 95 "parse.y"
  902. X{
  903. X            /* these productions are separate from the s1object
  904. X             * rule because the semantics must be done before
  905. X             * we parse the remainder of an s1object
  906. X             */
  907. X
  908. X            xcluflg = false;
  909. X            ;
  910. X    break;}
  911. Xcase 8:
  912. X#line 105 "parse.y"
  913. X{ xcluflg = true; ;
  914. X    break;}
  915. Xcase 9:
  916. X#line 109 "parse.y"
  917. X{ scinstal( nmstr, xcluflg ); ;
  918. X    break;}
  919. Xcase 10:
  920. X#line 112 "parse.y"
  921. X{ scinstal( nmstr, xcluflg ); ;
  922. X    break;}
  923. Xcase 11:
  924. X#line 115 "parse.y"
  925. X{ synerr( "bad start condition list" ); ;
  926. X    break;}
  927. Xcase 14:
  928. X#line 123 "parse.y"
  929. X{
  930. X            /* initialize for a parse of one rule */
  931. X            trlcontxt = variable_trail_rule = varlength = false;
  932. X            trailcnt = headcnt = rulelen = 0;
  933. X            current_state_type = STATE_NORMAL;
  934. X            previous_continued_action = continued_action;
  935. X            new_rule();
  936. X            ;
  937. X    break;}
  938. Xcase 15:
  939. X#line 134 "parse.y"
  940. X{
  941. X            pat = yyvsp[0];
  942. X            finish_rule( pat, variable_trail_rule,
  943. X                     headcnt, trailcnt );
  944. X
  945. X            for ( i = 1; i <= actvp; ++i )
  946. X                scbol[actvsc[i]] =
  947. X                mkbranch( scbol[actvsc[i]], pat );
  948. X
  949. X            if ( ! bol_needed )
  950. X                {
  951. X                bol_needed = true;
  952. X
  953. X                if ( performance_report )
  954. X                pinpoint_message( 
  955. X                "'^' operator results in sub-optimal performance" );
  956. X                }
  957. X            ;
  958. X    break;}
  959. Xcase 16:
  960. X#line 154 "parse.y"
  961. X{
  962. X            pat = yyvsp[0];
  963. X            finish_rule( pat, variable_trail_rule,
  964. X                     headcnt, trailcnt );
  965. X
  966. X            for ( i = 1; i <= actvp; ++i )
  967. X                scset[actvsc[i]] =
  968. X                mkbranch( scset[actvsc[i]], pat );
  969. X            ;
  970. X    break;}
  971. Xcase 17:
  972. X#line 165 "parse.y"
  973. X{
  974. X            pat = yyvsp[0];
  975. X            finish_rule( pat, variable_trail_rule,
  976. X                     headcnt, trailcnt );
  977. X
  978. X            /* add to all non-exclusive start conditions,
  979. X             * including the default (0) start condition
  980. X             */
  981. X
  982. X            for ( i = 1; i <= lastsc; ++i )
  983. X                if ( ! scxclu[i] )
  984. X                scbol[i] = mkbranch( scbol[i], pat );
  985. X
  986. X            if ( ! bol_needed )
  987. X                {
  988. X                bol_needed = true;
  989. X
  990. X                if ( performance_report )
  991. X                pinpoint_message(
  992. X                "'^' operator results in sub-optimal performance" );
  993. X                }
  994. X            ;
  995. X    break;}
  996. Xcase 18:
  997. X#line 189 "parse.y"
  998. X{
  999. X            pat = yyvsp[0];
  1000. X            finish_rule( pat, variable_trail_rule,
  1001. X                     headcnt, trailcnt );
  1002. X
  1003. X            for ( i = 1; i <= lastsc; ++i )
  1004. X                if ( ! scxclu[i] )
  1005. X                scset[i] = mkbranch( scset[i], pat );
  1006. X            ;
  1007. X    break;}
  1008. Xcase 19:
  1009. X#line 200 "parse.y"
  1010. X{ build_eof_action(); ;
  1011. X    break;}
  1012. Xcase 20:
  1013. X#line 203 "parse.y"
  1014. X{
  1015. X            /* this EOF applies to all start conditions
  1016. X             * which don't already have EOF actions
  1017. X             */
  1018. X            actvp = 0;
  1019. X
  1020. X            for ( i = 1; i <= lastsc; ++i )
  1021. X                if ( ! sceof[i] )
  1022. X                actvsc[++actvp] = i;
  1023. X
  1024. X            if ( actvp == 0 )
  1025. X                pinpoint_message(
  1026. X        "warning - all start conditions already have <<EOF>> rules" );
  1027. X
  1028. X            else
  1029. X                build_eof_action();
  1030. X            ;
  1031. X    break;}
  1032. Xcase 21:
  1033. X#line 222 "parse.y"
  1034. X{ synerr( "unrecognized rule" ); ;
  1035. X    break;}
  1036. Xcase 23:
  1037. X#line 229 "parse.y"
  1038. X{
  1039. X            if ( (scnum = sclookup( nmstr )) == 0 )
  1040. X                format_pinpoint_message(
  1041. X                "undeclared start condition %s", nmstr );
  1042. X
  1043. X            else
  1044. X                actvsc[++actvp] = scnum;
  1045. X            ;
  1046. X    break;}
  1047. Xcase 24:
  1048. X#line 239 "parse.y"
  1049. X{
  1050. X            if ( (scnum = sclookup( nmstr )) == 0 )
  1051. X                format_pinpoint_message(
  1052. X                "undeclared start condition %s", nmstr );
  1053. X            else
  1054. X                actvsc[actvp = 1] = scnum;
  1055. X            ;
  1056. X    break;}
  1057. Xcase 25:
  1058. X#line 248 "parse.y"
  1059. X{ synerr( "bad start condition list" ); ;
  1060. X    break;}
  1061. Xcase 26:
  1062. X#line 252 "parse.y"
  1063. X{
  1064. X            if ( transchar[lastst[yyvsp[0]]] != SYM_EPSILON )
  1065. X                /* provide final transition \now/ so it
  1066. X                 * will be marked as a trailing context
  1067. X                 * state
  1068. X                 */
  1069. X                yyvsp[0] = link_machines( yyvsp[0], mkstate( SYM_EPSILON ) );
  1070. X
  1071. X            mark_beginning_as_normal( yyvsp[0] );
  1072. X            current_state_type = STATE_NORMAL;
  1073. X
  1074. X            if ( previous_continued_action )
  1075. X                {
  1076. X                /* we need to treat this as variable trailing
  1077. X                 * context so that the backup does not happen
  1078. X                 * in the action but before the action switch
  1079. X                 * statement.  If the backup happens in the
  1080. X                 * action, then the rules "falling into" this
  1081. X                 * one's action will *also* do the backup,
  1082. X                 * erroneously.
  1083. X                 */
  1084. X                if ( ! varlength || headcnt != 0 )
  1085. X                {
  1086. X                fprintf( stderr,
  1087. X    "%s: warning - trailing context rule at line %d made variable because\n",
  1088. X                     program_name, linenum );
  1089. X                fprintf( stderr,
  1090. X                     "      of preceding '|' action\n" );
  1091. X                }
  1092. X
  1093. X                /* mark as variable */
  1094. X                varlength = true;
  1095. X                headcnt = 0;
  1096. X                }
  1097. X
  1098. X            if ( varlength && headcnt == 0 )
  1099. X                { /* variable trailing context rule */
  1100. X                /* mark the first part of the rule as the accepting
  1101. X                 * "head" part of a trailing context rule
  1102. X                 */
  1103. X                /* by the way, we didn't do this at the beginning
  1104. X                 * of this production because back then
  1105. X                 * current_state_type was set up for a trail
  1106. X                 * rule, and add_accept() can create a new
  1107. X                 * state ...
  1108. X                 */
  1109. X                add_accept( yyvsp[-1], num_rules | YY_TRAILING_HEAD_MASK );
  1110. X                variable_trail_rule = true;
  1111. X                }
  1112. X            
  1113. X            else
  1114. X                trailcnt = rulelen;
  1115. X
  1116. X            yyval = link_machines( yyvsp[-1], yyvsp[0] );
  1117. X            ;
  1118. X    break;}
  1119. Xcase 27:
  1120. X#line 309 "parse.y"
  1121. X{ synerr( "trailing context used twice" ); ;
  1122. X    break;}
  1123. Xcase 28:
  1124. X#line 312 "parse.y"
  1125. X{
  1126. X            if ( trlcontxt )
  1127. X                {
  1128. X                synerr( "trailing context used twice" );
  1129. X                yyval = mkstate( SYM_EPSILON );
  1130. X                }
  1131. X
  1132. X            else if ( previous_continued_action )
  1133. X                {
  1134. X                /* see the comment in the rule for "re2 re"
  1135. X                 * above
  1136. X                 */
  1137. X                if ( ! varlength || headcnt != 0 )
  1138. X                {
  1139. X                fprintf( stderr,
  1140. X    "%s: warning - trailing context rule at line %d made variable because\n",
  1141. X                     program_name, linenum );
  1142. X                fprintf( stderr,
  1143. X                     "      of preceding '|' action\n" );
  1144. X                }
  1145. X
  1146. X                /* mark as variable */
  1147. X                varlength = true;
  1148. X                headcnt = 0;
  1149. X                }
  1150. X
  1151. X            trlcontxt = true;
  1152. X
  1153. X            if ( ! varlength )
  1154. X                headcnt = rulelen;
  1155. X
  1156. X            ++rulelen;
  1157. X            trailcnt = 1;
  1158. X
  1159. X            eps = mkstate( SYM_EPSILON );
  1160. X            yyval = link_machines( yyvsp[-1],
  1161. X                 link_machines( eps, mkstate( '\n' ) ) );
  1162. X            ;
  1163. X    break;}
  1164. Xcase 29:
  1165. X#line 352 "parse.y"
  1166. X{
  1167. X                yyval = yyvsp[0];
  1168. X
  1169. X            if ( trlcontxt )
  1170. X                {
  1171. X                if ( varlength && headcnt == 0 )
  1172. X                /* both head and trail are variable-length */
  1173. X                variable_trail_rule = true;
  1174. X                else
  1175. X                trailcnt = rulelen;
  1176. X                }
  1177. X                ;
  1178. X    break;}
  1179. Xcase 30:
  1180. X#line 368 "parse.y"
  1181. X{
  1182. X            varlength = true;
  1183. X            yyval = mkor( yyvsp[-2], yyvsp[0] );
  1184. X            ;
  1185. X    break;}
  1186. Xcase 31:
  1187. X#line 374 "parse.y"
  1188. X{ yyval = yyvsp[0]; ;
  1189. X    break;}
  1190. Xcase 32:
  1191. X#line 379 "parse.y"
  1192. X{
  1193. X            /* this rule is written separately so
  1194. X             * the reduction will occur before the trailing
  1195. X             * series is parsed
  1196. X             */
  1197. X
  1198. X            if ( trlcontxt )
  1199. X                synerr( "trailing context used twice" );
  1200. X            else
  1201. X                trlcontxt = true;
  1202. X
  1203. X            if ( varlength )
  1204. X                /* we hope the trailing context is fixed-length */
  1205. X                varlength = false;
  1206. X            else
  1207. X                headcnt = rulelen;
  1208. X
  1209. X            rulelen = 0;
  1210. X
  1211. X            current_state_type = STATE_TRAILING_CONTEXT;
  1212. X            yyval = yyvsp[-1];
  1213. X            ;
  1214. X    break;}
  1215. Xcase 33:
  1216. X#line 404 "parse.y"
  1217. X{
  1218. X            /* this is where concatenation of adjacent patterns
  1219. X             * gets done
  1220. X             */
  1221. X            yyval = link_machines( yyvsp[-1], yyvsp[0] );
  1222. X            ;
  1223. X    break;}
  1224. Xcase 34:
  1225. X#line 412 "parse.y"
  1226. X{ yyval = yyvsp[0]; ;
  1227. X    break;}
  1228. Xcase 35:
  1229. X#line 416 "parse.y"
  1230. X{
  1231. X            varlength = true;
  1232. X
  1233. X            yyval = mkclos( yyvsp[-1] );
  1234. X            ;
  1235. X    break;}
  1236. Xcase 36:
  1237. X#line 423 "parse.y"
  1238. X{
  1239. X            varlength = true;
  1240. X
  1241. X            yyval = mkposcl( yyvsp[-1] );
  1242. X            ;
  1243. X    break;}
  1244. Xcase 37:
  1245. X#line 430 "parse.y"
  1246. X{
  1247. X            varlength = true;
  1248. X
  1249. X            yyval = mkopt( yyvsp[-1] );
  1250. X            ;
  1251. X    break;}
  1252. Xcase 38:
  1253. X#line 437 "parse.y"
  1254. X{
  1255. X            varlength = true;
  1256. X
  1257. X            if ( yyvsp[-3] > yyvsp[-1] || yyvsp[-3] < 0 )
  1258. X                {
  1259. X                synerr( "bad iteration values" );
  1260. X                yyval = yyvsp[-5];
  1261. X                }
  1262. X            else
  1263. X                {
  1264. X                if ( yyvsp[-3] == 0 )
  1265. X                yyval = mkopt( mkrep( yyvsp[-5], yyvsp[-3], yyvsp[-1] ) );
  1266. X                else
  1267. X                yyval = mkrep( yyvsp[-5], yyvsp[-3], yyvsp[-1] );
  1268. X                }
  1269. X            ;
  1270. X    break;}
  1271. Xcase 39:
  1272. X#line 455 "parse.y"
  1273. X{
  1274. X            varlength = true;
  1275. X
  1276. X            if ( yyvsp[-2] <= 0 )
  1277. X                {
  1278. X                synerr( "iteration value must be positive" );
  1279. X                yyval = yyvsp[-4];
  1280. X                }
  1281. X
  1282. X            else
  1283. X                yyval = mkrep( yyvsp[-4], yyvsp[-2], INFINITY );
  1284. X            ;
  1285. X    break;}
  1286. Xcase 40:
  1287. X#line 469 "parse.y"
  1288. X{
  1289. X            /* the singleton could be something like "(foo)",
  1290. X             * in which case we have no idea what its length
  1291. X             * is, so we punt here.
  1292. X             */
  1293. X            varlength = true;
  1294. X
  1295. X            if ( yyvsp[-1] <= 0 )
  1296. X                {
  1297. X                synerr( "iteration value must be positive" );
  1298. X                yyval = yyvsp[-3];
  1299. X                }
  1300. X
  1301. X            else
  1302. X                yyval = link_machines( yyvsp[-3], copysingl( yyvsp[-3], yyvsp[-1] - 1 ) );
  1303. X            ;
  1304. X    break;}
  1305. Xcase 41:
  1306. X#line 487 "parse.y"
  1307. X{
  1308. X            if ( ! madeany )
  1309. X                {
  1310. X                /* create the '.' character class */
  1311. X                anyccl = cclinit();
  1312. X                ccladd( anyccl, '\n' );
  1313. X                cclnegate( anyccl );
  1314. X
  1315. X                if ( useecs )
  1316. X                mkeccl( ccltbl + cclmap[anyccl],
  1317. X                    ccllen[anyccl], nextecm,
  1318. X                    ecgroup, csize, csize );
  1319. X
  1320. X                madeany = true;
  1321. X                }
  1322. X
  1323. X            ++rulelen;
  1324. X
  1325. X            yyval = mkstate( -anyccl );
  1326. X            ;
  1327. X    break;}
  1328. Xcase 42:
  1329. X#line 509 "parse.y"
  1330. X{
  1331. X            if ( ! cclsorted )
  1332. X                /* sort characters for fast searching.  We use a
  1333. X                 * shell sort since this list could be large.
  1334. X                 */
  1335. X                cshell( ccltbl + cclmap[yyvsp[0]], ccllen[yyvsp[0]], true );
  1336. X
  1337. X            if ( useecs )
  1338. X                mkeccl( ccltbl + cclmap[yyvsp[0]], ccllen[yyvsp[0]],
  1339. X                    nextecm, ecgroup, csize, csize );
  1340. X
  1341. X            ++rulelen;
  1342. X
  1343. X            yyval = mkstate( -yyvsp[0] );
  1344. X            ;
  1345. X    break;}
  1346. Xcase 43:
  1347. X#line 526 "parse.y"
  1348. X{
  1349. X            ++rulelen;
  1350. X
  1351. X            yyval = mkstate( -yyvsp[0] );
  1352. X            ;
  1353. X    break;}
  1354. Xcase 44:
  1355. X#line 533 "parse.y"
  1356. X{ yyval = yyvsp[-1]; ;
  1357. X    break;}
  1358. Xcase 45:
  1359. X#line 536 "parse.y"
  1360. X{ yyval = yyvsp[-1]; ;
  1361. X    break;}
  1362. Xcase 46:
  1363. X#line 539 "parse.y"
  1364. X{
  1365. X            ++rulelen;
  1366. X
  1367. X            if ( caseins && yyvsp[0] >= 'A' && yyvsp[0] <= 'Z' )
  1368. X                yyvsp[0] = clower( yyvsp[0] );
  1369. X
  1370. X            yyval = mkstate( yyvsp[0] );
  1371. X            ;
  1372. X    break;}
  1373. Xcase 47:
  1374. X#line 550 "parse.y"
  1375. X{ yyval = yyvsp[-1]; ;
  1376. X    break;}
  1377. Xcase 48:
  1378. X#line 553 "parse.y"
  1379. X{
  1380. X            /* *Sigh* - to be compatible Unix lex, negated ccls
  1381. X             * match newlines
  1382. X             */
  1383. X#ifdef NOTDEF
  1384. X            ccladd( yyvsp[-1], '\n' ); /* negated ccls don't match '\n' */
  1385. X            cclsorted = false; /* because we added the newline */
  1386. X#endif
  1387. X            cclnegate( yyvsp[-1] );
  1388. X            yyval = yyvsp[-1];
  1389. X            ;
  1390. X    break;}
  1391. Xcase 49:
  1392. X#line 567 "parse.y"
  1393. X{
  1394. X            if ( yyvsp[-2] > yyvsp[0] )
  1395. X                synerr( "negative range in character class" );
  1396. X
  1397. X            else
  1398. X                {
  1399. X                if ( caseins )
  1400. X                {
  1401. X                if ( yyvsp[-2] >= 'A' && yyvsp[-2] <= 'Z' )
  1402. X                    yyvsp[-2] = clower( yyvsp[-2] );
  1403. X                if ( yyvsp[0] >= 'A' && yyvsp[0] <= 'Z' )
  1404. X                    yyvsp[0] = clower( yyvsp[0] );
  1405. X                }
  1406. X
  1407. X                for ( i = yyvsp[-2]; i <= yyvsp[0]; ++i )
  1408. X                    ccladd( yyvsp[-3], i );
  1409. X
  1410. X                /* keep track if this ccl is staying in alphabetical
  1411. X                 * order
  1412. X                 */
  1413. X                cclsorted = cclsorted && (yyvsp[-2] > lastchar);
  1414. X                lastchar = yyvsp[0];
  1415. X                }
  1416. X
  1417. X            yyval = yyvsp[-3];
  1418. X            ;
  1419. X    break;}
  1420. Xcase 50:
  1421. X#line 595 "parse.y"
  1422. X{
  1423. X            if ( caseins )
  1424. X                if ( yyvsp[0] >= 'A' && yyvsp[0] <= 'Z' )
  1425. X                yyvsp[0] = clower( yyvsp[0] );
  1426. X
  1427. X            ccladd( yyvsp[-1], yyvsp[0] );
  1428. X            cclsorted = cclsorted && (yyvsp[0] > lastchar);
  1429. X            lastchar = yyvsp[0];
  1430. X            yyval = yyvsp[-1];
  1431. X            ;
  1432. X    break;}
  1433. Xcase 51:
  1434. X#line 607 "parse.y"
  1435. X{
  1436. X            cclsorted = true;
  1437. X            lastchar = 0;
  1438. X            yyval = cclinit();
  1439. X            ;
  1440. X    break;}
  1441. Xcase 52:
  1442. X#line 615 "parse.y"
  1443. X{
  1444. X            if ( caseins )
  1445. X                if ( yyvsp[0] >= 'A' && yyvsp[0] <= 'Z' )
  1446. X                yyvsp[0] = clower( yyvsp[0] );
  1447. X
  1448. X            ++rulelen;
  1449. X
  1450. X            yyval = link_machines( yyvsp[-1], mkstate( yyvsp[0] ) );
  1451. X            ;
  1452. X    break;}
  1453. Xcase 53:
  1454. X#line 626 "parse.y"
  1455. X{ yyval = mkstate( SYM_EPSILON ); ;
  1456. X    break;}
  1457. X}
  1458. X   /* the action file gets copied in in place of this dollarsign */
  1459. X#line 303 "bison.simple"
  1460. X
  1461. X  yyvsp -= yylen;
  1462. X  yyssp -= yylen;
  1463. X#ifdef YYLSP_NEEDED
  1464. X  yylsp -= yylen;
  1465. X#endif
  1466. X
  1467. X#ifdef YYDEBUG
  1468. X  if (yydebug)
  1469. X    {
  1470. X      short *ssp1 = yyss - 1;
  1471. X      fprintf (stderr, "state stack now");
  1472. X      while (ssp1 != yyssp)
  1473. X        fprintf (stderr, " %d", *++ssp1);
  1474. X      fprintf (stderr, "\n");
  1475. X    }
  1476. X#endif
  1477. X
  1478. X  *++yyvsp = yyval;
  1479. X
  1480. X#ifdef YYLSP_NEEDED
  1481. X  yylsp++;
  1482. X  if (yylen == 0)
  1483. X    {
  1484. X      yylsp->first_line = yylloc.first_line;
  1485. X      yylsp->first_column = yylloc.first_column;
  1486. X      yylsp->last_line = (yylsp-1)->last_line;
  1487. X      yylsp->last_column = (yylsp-1)->last_column;
  1488. X      yylsp->text = 0;
  1489. X    }
  1490. X  else
  1491. X    {
  1492. X      yylsp->last_line = (yylsp+yylen-1)->last_line;
  1493. X      yylsp->last_column = (yylsp+yylen-1)->last_column;
  1494. X    }
  1495. X#endif
  1496. X
  1497. X  /* Now "shift" the result of the reduction.
  1498. X     Determine what state that goes to,
  1499. X     based on the state we popped back to
  1500. X     and the rule number reduced by.  */
  1501. X
  1502. X  yyn = yyr1[yyn];
  1503. X
  1504. X  yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  1505. X  if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  1506. X    yystate = yytable[yystate];
  1507. X  else
  1508. X    yystate = yydefgoto[yyn - YYNTBASE];
  1509. X
  1510. X  goto yynewstate;
  1511. X
  1512. Xyyerrlab:   /* here on detecting error */
  1513. X
  1514. X  if (! yyerrstatus)
  1515. X    /* If not already recovering from an error, report this error.  */
  1516. X    {
  1517. X      ++yynerr;
  1518. X      yyerror("parse error");
  1519. X    }
  1520. X
  1521. X  if (yyerrstatus == 3)
  1522. X    {
  1523. X      /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  1524. X
  1525. X      /* return failure if at end of input */
  1526. X      if (yychar == YYEOF)
  1527. X        YYERROR;
  1528. X
  1529. X#ifdef YYDEBUG
  1530. X      if (yydebug)
  1531. X        fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  1532. X#endif
  1533. X
  1534. X      yychar = YYEMPTY;
  1535. X    }
  1536. X
  1537. X  /* Else will try to reuse lookahead token
  1538. X     after shifting the error token.  */
  1539. X
  1540. X  yyerrstatus = 3;              /* Each real token shifted decrements this */
  1541. X
  1542. X  goto yyerrhandle;
  1543. X
  1544. Xyyerrdefault:  /* current state does not do anything special for the error token. */
  1545. X
  1546. X#if 0
  1547. X  /* This is wrong; only states that explicitly want error tokens
  1548. X     should shift them.  */
  1549. X  yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  1550. X  if (yyn) goto yydefault;
  1551. X#endif
  1552. X
  1553. Xyyerrpop:   /* pop the current state because it cannot handle the error token */
  1554. X
  1555. X  if (yyssp == yyss) YYERROR;
  1556. X  yyvsp--;
  1557. X  yystate = *--yyssp;
  1558. X#ifdef YYLSP_NEEDED
  1559. X  yylsp--;
  1560. X#endif
  1561. X
  1562. X#ifdef YYDEBUG
  1563. X  if (yydebug)
  1564. X    {
  1565. X      short *ssp1 = yyss - 1;
  1566. X      fprintf (stderr, "Error: state stack now");
  1567. X      while (ssp1 != yyssp)
  1568. X        fprintf (stderr, " %d", *++ssp1);
  1569. X      fprintf (stderr, "\n");
  1570. X    }
  1571. X#endif
  1572. X
  1573. Xyyerrhandle:
  1574. X
  1575. X  yyn = yypact[yystate];
  1576. X  if (yyn == YYFLAG)
  1577. X    goto yyerrdefault;
  1578. X
  1579. X  yyn += YYTERROR;
  1580. X  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  1581. X    goto yyerrdefault;
  1582. X
  1583. X  yyn = yytable[yyn];
  1584. X  if (yyn < 0)
  1585. X    {
  1586. X      if (yyn == YYFLAG)
  1587. X        goto yyerrpop;
  1588. X      yyn = -yyn;
  1589. X      goto yyreduce;
  1590. X    }
  1591. X  else if (yyn == 0)
  1592. X    goto yyerrpop;
  1593. X
  1594. X  if (yyn == YYFINAL)
  1595. X    YYACCEPT;
  1596. X
  1597. X#ifdef YYDEBUG
  1598. X  if (yydebug)
  1599. X    fprintf(stderr, "Shifting error token, ");
  1600. X#endif
  1601. X
  1602. X  *++yyvsp = yylval;
  1603. X#ifdef YYLSP_NEEDED
  1604. X  *++yylsp = yylloc;
  1605. X#endif
  1606. X
  1607. X  yystate = yyn;
  1608. X  goto yynewstate;
  1609. X}
  1610. X#line 629 "parse.y"
  1611. X
  1612. X
  1613. X
  1614. X/* build_eof_action - build the "<<EOF>>" action for the active start
  1615. X *                    conditions
  1616. X */
  1617. X
  1618. Xvoid build_eof_action()
  1619. X
  1620. X    {
  1621. X    register int i;
  1622. X
  1623. X    for ( i = 1; i <= actvp; ++i )
  1624. X    {
  1625. X    if ( sceof[actvsc[i]] )
  1626. X        format_pinpoint_message(
  1627. X        "multiple <<EOF>> rules for start condition %s",
  1628. X            scname[actvsc[i]] );
  1629. X
  1630. X    else
  1631. X        {
  1632. X        sceof[actvsc[i]] = true;
  1633. X        fprintf( temp_action_file, "case YY_STATE_EOF(%s):\n",
  1634. X             scname[actvsc[i]] );
  1635. X        }
  1636. X    }
  1637. X
  1638. X    line_directive_out( temp_action_file );
  1639. X    }
  1640. X
  1641. X
  1642. X/* synerr - report a syntax error */
  1643. X
  1644. Xvoid synerr( str )
  1645. Xchar str[];
  1646. X
  1647. X    {
  1648. X    syntaxerror = true;
  1649. X    pinpoint_message( str );
  1650. X    }
  1651. X
  1652. X
  1653. X/* format_pinpoint_message - write out a message formatted with one string,
  1654. X *                 pinpointing its location
  1655. X */
  1656. X
  1657. Xvoid format_pinpoint_message( msg, arg )
  1658. Xchar msg[], arg[];
  1659. X
  1660. X    {
  1661. X    char errmsg[MAXLINE];
  1662. X
  1663. X    (void) sprintf( errmsg, msg, arg );
  1664. X    pinpoint_message( errmsg );
  1665. X    }
  1666. X
  1667. X
  1668. X/* pinpoint_message - write out a message, pinpointing its location */
  1669. X
  1670. Xvoid pinpoint_message( str )
  1671. Xchar str[];
  1672. X
  1673. X    {
  1674. X    fprintf( stderr, "\"%s\", line %d: %s\n", infilename, linenum, str );
  1675. X    }
  1676. X
  1677. X
  1678. X/* yyerror - eat up an error message from the parser;
  1679. X *         currently, messages are ignore
  1680. X */
  1681. X
  1682. Xvoid yyerror( msg )
  1683. Xchar msg[];
  1684. X
  1685. X    {
  1686. X    }
  1687. END_OF_FILE
  1688. if test 45081 -ne `wc -c <'parse.c'`; then
  1689.     echo shar: \"'parse.c'\" unpacked with wrong size!
  1690. fi
  1691. # end of 'parse.c'
  1692. fi
  1693. echo shar: End of archive 8 \(of 13\).
  1694. cp /dev/null ark8isdone
  1695. MISSING=""
  1696. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 ; do
  1697.     if test ! -f ark${I}isdone ; then
  1698.     MISSING="${MISSING} ${I}"
  1699.     fi
  1700. done
  1701. if test "${MISSING}" = "" ; then
  1702.     echo You have unpacked all 13 archives.
  1703.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1704. else
  1705.     echo You still need to unpack the following archives:
  1706.     echo "        " ${MISSING}
  1707. fi
  1708. ##  End of shell archive.
  1709. exit 0
  1710. -- 
  1711. Mail submissions (sources or binaries) to <amiga@uunet.uu.net>.
  1712. Mail comments to the moderator at <amiga-request@uunet.uu.net>.
  1713. Post requests for sources, and general discussion to comp.sys.amiga.
  1714.